﻿
@{
    Layout = null;
}



<link href="~/libs/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />


<div class="layui-row">
    <div class="layui-col-xs4">
        <div class="grid-demo grid-demo-bg1">
            <div id="ID-tree-demo-showCheckbox"></div>
        </div>
    </div>
    <div class="layui-col-xs8">
        <div class="grid-demo">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">产品物料编码</label>
                    <div class="layui-input-inline ">
                        <input type="text" id="materialCode" name="materialCode" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入产品物料编码">
                    </div>
                    <label class="layui-form-label">仓库名称</label>
                    <div class="layui-input-inline ">
                        <input type="text" id="warehouse" name="warehouse" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入仓库名称">
                    </div>
                    <div>
                        <button type="button" id="btnSearch" class="layui-btn layui-btn-sm layui-bg-blue">搜索</button>
                        <button type="button" class="layui-btn  layui-btn-primary  layui-btn-sm">重置</button>
                    </div>
                </div>
            </form>
            <table class="layui-hide" id="GetLvnventoryOnhand" name="GetLvnventoryOnhand"></table>
        </div>
    </div>
</div>
            <script src="~/libs/jquery/jquery.js"></script>
            <script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
            <script>
                layui.use('table', function () {
                    var table = layui.table;
                    var from = layui.from;
                    var laydata = layui.laydata;
                    var tree = layui.tree;
                    var inst = table.render({});
                    // 已知数据渲染
                    function select() {
                        table.render({
                            elem: '#GetLvnventoryOnhand',
                            url: '/LvnventoryOnhand/GetLvnventoryOnhandList',
                            cols: [[ //标题栏
                                { type: 'checkbox', fixed: 'left' },
                                { field: 'materialCode', title: '产品物料编码', width: 100 },
                                { field: 'materialName', title: '产品物料名称', width: 100 },
                                { field: 'specificationsModels', title: '规格型号', width: 100 },
                                { field: 'instockNum', title: '在库数量', width: 100 },
                                { field: 'unit', title: '单位', width: 100 },
                                { field: 'warehouse', title: '仓库', width: 100 },
                                { field: 'reservoirArea', title: '库区', width: 100 },
                                { field: 'binLocation', title: '库位', width: 100 },
                                { field: 'supplierManagementCode', title: '供应商编码', width: 100 },
                                { field: 'supplierName', title: '供应商名称', width: 100 },
                                { field: 'supplierAbbreviation', title: '供应商简称', width: 100 },
                                { field: 'productionWorkOrders', title: '生产工单', width: 100 },
                                { field: 'lbounTime', title: '入库时间', width: 100 },
                                { field: 'lvnventoryTime', title: '库存有效期', width: 100 },
                                {
                                    field: 'isFreeze', title: '是否冻结', width: 100,
                                    templet: function (d) {
                                        return d.isFreeze ? "是" : "否"
                                    }
                                },

                            ]],

                            //skin: 'line', // 表格风格
                            //even: true,
                            page: true, // 是否显示分页
                            height: 500,
                            limits: [5, 10, 20, 30],
                            limit: 10, // 每页默认显示的数量
                            where: {
                                pageIndex: 1,
                                pageSize: 10
                            }
                        });
                    }

                  
                    function getMaterialTypes() {
                        $.ajax({
                            url: '/LvnventoryOnhand/GetMaterialTypeTree',
                            type: 'get',
                            dataType: 'json',
                            success: function (res) {
                                // 模拟数据
                                var data = res;

                                // 渲染
                                tree.render({
                                    elem: '#ID-tree-demo-showCheckbox',
                                    data: data,
                                    showLine: false,  // 是否开启连接线
                                    click: function (obj) {
                                        console.log(obj.data);

                                    }
                                    //showCheckbox: true,
                                });
                            }
                        })
                    }
                    getMaterialTypes();
                    select();
                   


                    //查询
                    $("#btnSearch").on("click", function () {
                        table.reload("GetLvnventoryOnhand", {
                            page: { curr: 1 },
                            where: {
                                materialCode: $("#materialCode").val(),
                                warehouse: $("#warehouse").val(),
                            },

                        })
                        return false;
                    })



                });
            </script>


